package edu.hadassah.prettyprint.printer.xmlprinter;

import edu.hadassah.prettyprint.doc.xml.Attribute;
import edu.hadassah.prettyprint.doc.xml.Comment;
import edu.hadassah.prettyprint.doc.xml.Tag;
import edu.hadassah.prettyprint.doc.xml.Text;
import edu.hadassah.prettyprint.printer.IDocumentPrinterVisitor;

public class XmlPrinterVisitor implements IDocumentPrinterVisitor {

	private final XMLDocumentPrinter printer;

	public XmlPrinterVisitor(XMLDocumentPrinter printer) {
		this.printer = printer;
	}

	/* (non-Javadoc)
	 * @see edu.hadassah.prettyprint.doc.IVisitor#visit(java.lang.Object)
	 */
	public void visit(Object obj) {
		if (obj instanceof Attribute){
			printer.print((Attribute)obj);
		} else if (obj instanceof Comment){
			printer.print((Comment)obj);
		} else if (obj instanceof Tag){
			printer.printStart((Tag)obj);
		} else if (obj instanceof Text){
			printer.print((Text)obj);
		} 
	}
	public String getResultString(){
		return printer.getResultString();
	}

}
